Binned CO2 vs Air Quality Plot


In [1]:
import pandas as pd
from bokeh.plotting import figure
from bokeh.io import show

bin = input("How many minutes would you like to bin by? Type that number followed by a capital T, all enclosed in single quotes ")


How many minutes would you like to bin by? Type that number followed by a capital T, all enclosed in single quotes '40T'

Use the pandas resample method to bin the file according to time


In [2]:
df1 = pd.read_csv(input("Name of CO2 file: "))

df1 = df1[['deviceTime_unix','co2_ppm']].copy()

df1 = df1.set_index(['deviceTime_unix'])
df1.index = pd.to_datetime(df1.index, unit='s')

df_binned = df1.resample(bin).mean().dropna().reset_index()


Name of CO2 file: 'chs_os_adc.csv'

In [3]:
df2 = pd.read_csv(input('Name of Air Quality File: '))
aqType = input("Name the air quality data you would like to use")

df2 = df2[['deviceTime_unix',aqType]].copy()

df2 = df2.set_index(['deviceTime_unix'])
df2.index = pd.to_datetime(df2.index, unit='s')
df2_binned = df2.resample(bin).mean().dropna().reset_index()


Name of Air Quality File: 'chs_os_aq.csv'
Name the air quality data you would like to use'PM25'

In [4]:
p = figure()
p.circle(y=df2_binned['PM25'],x=df_binned['co2_ppm'], color = "red")

show(p)


/Users/albertqiang/anaconda2/lib/python2.7/site-packages/bokeh/models/sources.py:89: BokehUserWarning: ColumnDataSource's columns must be of the same length
  lambda: warnings.warn("ColumnDataSource's columns must be of the same length", BokehUserWarning))